package view.status;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;

import controller.Controller;
import model.playable.Playable;
import model.visibility.PlayerView;
import view.Screen;
import view.img.ImageLibrary;

public class StatusPanel extends Screen
{ final static Dimension size = new Dimension(825,65);//842,75
  PlayerView playerView;
  Controller controller;
  public StatusPanel(PlayerView _playerView, Controller _controller)
  { super(size); 
  controller = _controller;
    playerView = _playerView;
  }
  
  public void paintComponent(Graphics g) 
  { Playable unit = controller.getCurrentPlayable();
    String id = String.format( "%d", unit.getIdNumber() );
    String upk = String.format( "%d", unit.getUpkeep() );
    String ore = String.format( "%d", playerView.getPlayerOre() );
    String food = String.format( "%d", playerView.getPlayerFood() );
    String energy = String.format( "%d", playerView.getPlayerEnergy() );
    
    Boolean pow = unit.getIsPoweredDown(), 
            sby = unit.getIsInStandBy();

    // hp  unit.get,
    // atk ,
    // amr ,
    // def ,

      
    int xPad = 25;
    // Background
    g.drawImage(ImageLibrary.getImage("status"), 0, 0, this);
    
    // Commands
    g.drawImage(ImageLibrary.getImage("command"), xPad, 25, this); 
    String c = controller.getCurrentCommandName();
    g.setColor(Color.green);
    g.drawString(c,xPad+20,40);
    
    // Rally Grid
    g.drawImage(ImageLibrary.getImage("rallyGrid"),xPad, 60, this);
    
    // Currently Selected
    g.drawImage(ImageLibrary.getImage("currentlySelected"), xPad, 250, this);
  
    // Currently Selected unit
    String selected = controller.getCurrentPlayable().toString();
    g.drawImage(ImageLibrary.getImage(selected), xPad+70, 260, this);
    g.drawString(selected, xPad+20, 300);
    
    // Currently Selected Stats
    int statPad = 60;
    g.drawString(id, xPad+statPad , 365);
    g.drawString(upk, xPad+statPad , 385);
    
    if( pow )
    { g.drawString("Down", xPad+statPad , 505); }
    else
    { g.drawString("Up", xPad+statPad , 505); }
    
    if( sby )
    { g.drawString("Idle", xPad+statPad , 525); }
    else
    { g.drawString("Active", xPad+statPad , 525); }
    
    // Resource Label
    g.drawImage(ImageLibrary.getImage("resourceBar"), xPad, 550, this);
    g.drawString(energy, xPad+35, 565);
    g.drawString(ore,    xPad+35, 592);
    g.drawString(food,   xPad+35, 617);
  }
}